<template>
	
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onLoad(options) {
			// #ifdef H5
			if (options.gopay != 1 && options.pay_code == 'weixin'){
				var pages = getCurrentPages(); //当前页
				var beforePage = pages[pages.length - 2]; //上个页面
				if (typeof(beforePage) != 'undefined'){
					uni.setStorageSync("beforeUrl", '/'+beforePage.route+'?'+this.app.toParams(beforePage.options));
				} 
				window.location.href = window.location.href+'&gopay=1';//微信支付，限制支付目录，进行跳转处理
				return true;
			}
			// #endif
			this.goPay(options);
		},
		computed: {},
		onReady() {},
		methods: {
			async goPay(options){
				switch (options.pay_code) {
					case 'alipayMobile':
					case 'alipayApp':
						await this.$mPayment.aliPay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
						break;
					case 'weixin':
					case 'appWeixinPay':
						await this.$mPayment.weixinPay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
						break;
					case 'balance':
						await this.$mPayment.balancePay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
						break;
					case 'bean':
						await this.$mPayment.beanPay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
						break;
					case 'goodsMoney':
						await this.$mPayment.goodsMoneyPay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
					break;
					case 'uplevelGoodsMoney':
						await this.$mPayment.uplevelGoodsMoneyPay(this,options.pay_code,options.from,options.payType,options.order_id,options.route);
					break;
					default:
						this.app.showModal('暂不支持.',-1);
						break;
				}
			}
		}
	}
</script>

<style lang="scss">
	
	

</style>
